package com.cd.cms.common.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;

public class JsonUtil {
	/**
	 * 传入任意的jsontext,返回的T都不会为null,只是T的属性为null
	 * 
	 * @param <T>
	 * @param jsontext
	 * @param clazz
	 * @return -> UserBean
	 */
	public static final <T> T getObject(String jsontext, Class<T> clazz) {
		return JSON.parseObject(jsontext, clazz);
	}
	
	public static final <T> T getObject(JSON json, Class<T> clazz) {
		return JSON.toJavaObject(json, clazz);
	}
	
	public static final String toJSONString(Object object) {
		return JSON.toJSONString(object, false);
	}

	public static final String toJSONString(Object object, boolean prettyFormat) {
		return JSON.toJSONString(object, prettyFormat);
	}
	
	public static final String toJSONString(Object object, SimplePropertyPreFilter spp) {
        return JSON.toJSONString(object, spp);  
    }
}

